package com.sh.rbac.job;

import com.sh.rbac.mapper.LoginLogMapper;
import com.sh.rbac.mapper.OperationLogMapper;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

/**
 * 清除系统日志
 *
 * @author wb
 * @since 2024-08-06
 */

@Slf4j
@Component
public class CleanSystemLogJob extends QuartzJobBean {

    @Autowired
    private LoginLogMapper loginLogMapper;

    @Autowired
    private OperationLogMapper operationLogMapper;

    @Override
    protected void executeInternal(JobExecutionContext context) {
        Integer loginLogCount = loginLogMapper.clearData(2);
        log.info("清除登录日志{}条", loginLogCount);

        Integer operationLogCount = operationLogMapper.clearData(2);
        log.info("清除操作日志{}条", operationLogCount);
    }
}
